package com.thinkingstar.iads.cs.sys.enumerate;

import java.util.LinkedList;
import java.util.List;

public enum WIDGET_TYPE {
	
	
	图片("image","图片"),
	文本框("text","文本框"),
	文本域("textarea","文本域"),
	文件("file","文件"),
	PDF("pdf","pdf"),
	EXCEL("excel","excel"),
	WORD("word","word"),
	DWG("dwg","CAD图纸"),
	
	行内文本("inline_text","行内文本"),
	行内文本域("inline_textarea","行内文本域"),
	下拉选("select","下拉选"),
	复合多选框("checkbox","复合多选框"),
	结构化图片("image_div","结构化图片"),
	复合单选框("radio","复合单选框");
	
	
	private final String code;
	private final String desc;
	
	private WIDGET_TYPE(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public String getDesc() {
		return desc;
	}

	public String getCode() {
		return code;
	}
	
	public static List <WIDGET_TYPE> getAllCode(){
		List <WIDGET_TYPE> all_data = new LinkedList<>();
		all_data.add(图片);
		all_data.add(文件);
		all_data.add(文本框);
		all_data.add(文本域);
		all_data.add(EXCEL);
		all_data.add(PDF);
		all_data.add(WORD);
		all_data.add(DWG);
		return all_data;
	}
	
	public static List<WIDGET_TYPE> getAllFileCode(){
		List <WIDGET_TYPE> all_data = new LinkedList<>();
		all_data.add(EXCEL);
		all_data.add(PDF);
		all_data.add(WORD);
		all_data.add(DWG);
		return all_data;
	}
	
	public static WIDGET_TYPE getWidgetTypeByCode(String code){
		List <WIDGET_TYPE> data_list = getAllFileCode();
		for(WIDGET_TYPE widget_TYPE : data_list){
			if(code.equals(widget_TYPE.getCode())){
				return widget_TYPE;
			}
		}
		return null;
	}

}
